/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.totoland.web.controller.printing;

import com.totoland.web.controller.BaseController;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.bean.ViewScoped;
import org.primefaces.event.FileUploadEvent;
import org.primefaces.model.DefaultStreamedContent;
import org.primefaces.model.StreamedContent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 *
 * @author Totoland
 */
@ManagedBean
@SessionScoped
public class MananageTemplateController extends BaseController {

    private static final Logger LOGGER = LoggerFactory.getLogger(MananageTemplateController.class);
    private static final long serialVersionUID = 4803835898953919120L;

    private StreamedContent graphicText;

    @PostConstruct
    public void init() {
        
    }

    public void uploadTemplate(FileUploadEvent event) throws IOException {
        addInfo(event.getFile().getFileName() + " is uploaded.");
               
        graphicText = new DefaultStreamedContent(new ByteArrayInputStream(event.getFile().getContents()),event.getFile().getContentType());
    }

    public void save() {
    }

    @Override
    public void resetForm() {

    }

    /**
     * @return the graphicText
     */
    public StreamedContent getGraphicText() {
        return graphicText;
    }

    /**
     * @param graphicText the graphicText to set
     */
    public void setGraphicText(StreamedContent graphicText) {
        this.graphicText = graphicText;
    }

}
